import * as vscode from 'vscode';
import {dedent} from "../../../utils";

// documentation中使用了代码块，代码块中写的事makedown格式，首行不能为空
let actionItems = [
    {
        "label": "runAction",
        "insertText": `
        runAction(\${1:widget}, \${2:value})
        `,
        "documentation": `
        # 播放动作
        ## runAction(widget, value)

        | 参数   | 必选 | 类型 | 注释     |
        | :----- | :--- | :--- | :------- |
        | widget | 是   | obj  | 控件对象 |
        | value  | 是   | obj  | 动作内容 |
        `
    }
];




export function getCompletionItems(): vscode.CompletionItem[] {


    const completionItems: vscode.CompletionItem[] = [];
    actionItems.forEach((item: any) => {
        completionItems.push(createFunctionCompletionItem(item.label, item.insertText, item.documentation));
    });
    return completionItems;
}

function createFunctionCompletionItem(label: string, insertText: string, documentation?: string): vscode.CompletionItem {
    const item = new vscode.CompletionItem(label, vscode.CompletionItemKind.Function);
    item.insertText = new vscode.SnippetString(insertText);
    if (documentation) {
        item.documentation = new vscode.MarkdownString(documentation);
    }
    return item;
}
